🎖️GitЯра🎖️
Node / meshtastic / Meshtastic-Android / files / androidApp / src / main / kotlin / org / meshtastic / app / map / MapLayer.kt
Displaying Raw • Download
androidApp/src/main/kotlin/org/meshtastic/app/map/MapLayer.kt renovate/fastlane-2.x-lockfile (056eed64) Text, 2.18 KB
T8b949e/*
* Copyright (c) 2026 Meshtastic LLC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
Tff7b72package T7ee787org.meshtastic.app.map
Tff7b72import T7ee787java.io.InputStream
T8b949e// All that is left of the Android side of map layers once the store moved to `feature/map`: sniffing a stream, which
T8b949e// only this app's KML/KMZ readers do.
T8b949e/** Zip magic bytes; a KML-typed source starting with these is a KMZ archive rather than bare KML. */
Tff7b72private Tff7b72val Te6edf3KMZ_MAGIC Tff7b72= Te6edf3byteArrayOfTb4b4b4(Ta5d6ff'P'Tb4b4b4.Te6edf3codeTb4b4b4.Te6edf3toByteTb4b4b4(Tb4b4b4)Tb4b4b4, Ta5d6ff'K'Tb4b4b4.Te6edf3codeTb4b4b4.Te6edf3toByteTb4b4b4(Tb4b4b4)Tb4b4b4)
T8b949e/**
* True if [this] starts with the zip magic bytes, meaning a nominally-[LayerType.KML] source (`.kml` and `.kmz` both
* resolve to that one type — see [KML_EXTENSIONS]) is actually a KMZ archive. Shared by both flavors' parsers so
* neither has to duplicate the sniff or trust the file extension, which the content resolver can get wrong.
*
* Requires a mark-capable stream (wrap with [java.io.BufferedInputStream] first if unsure); leaves the stream position
* unchanged either way.
*/
Tff7b72fun Te6edf3InputStreamTb4b4b4.Td2a8ffisKmzArchiveTb4b4b4(Tb4b4b4)Tb4b4b4: Tffa657Boolean Tb4b4b4{
Te6edf3markTb4b4b4(Te6edf3KMZ_MAGICTb4b4b4.Te6edf3sizeTb4b4b4)
Tff7b72val Te6edf3magic Tff7b72= Te6edf3ByteArrayTb4b4b4(Te6edf3KMZ_MAGICTb4b4b4.Te6edf3sizeTb4b4b4)
T8b949e// read(ByteArray) is only guaranteed to return at least 1 byte before EOF, not to fill the buffer — loop rather
T8b949e// than trust a single call, or a short read could misclassify a real KMZ as bare KML.
Tff7b72var Te6edf3totalRead Tff7b72= T79c0ff0
Tff7b72while Tb4b4b4(Te6edf3totalRead Tff7b72< Te6edf3magicTb4b4b4.Te6edf3sizeTb4b4b4) Tb4b4b4{
Tff7b72val Te6edf3read Tff7b72= Te6edf3readTb4b4b4(Te6edf3magicTb4b4b4, Te6edf3totalReadTb4b4b4, Te6edf3magicTb4b4b4.Te6edf3size Tff7b72- Te6edf3totalReadTb4b4b4)
Tff7b72if Tb4b4b4(Te6edf3read Tff7b72=Tff7b72= Tff7b72-T79c0ff1Tb4b4b4) Tff7b72break
Te6edf3totalRead Tff7b72+Tff7b72= Te6edf3read
Tb4b4b4}
Te6edf3resetTb4b4b4(Tb4b4b4)
Tff7b72return Te6edf3totalRead Tff7b72=Tff7b72= Te6edf3KMZ_MAGICTb4b4b4.Te6edf3size Tff7b72&Tff7b72& Te6edf3magicTb4b4b4.Te6edf3contentEqualsTb4b4b4(Te6edf3KMZ_MAGICTb4b4b4)
Tb4b4b4}
Served by rngit 1.5.2 - Generated in 0.05s